#ifndef _IO_PORT_H_
#define _IO_PORT_H_

#include <types.h>

#define inb(port) ({ \
uchar _v; \
__asm__ __volatile__ ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
_v; \
})

#define outb(port, value) \
__asm__ __volatile__ ("outb %%al, %%dx" :: "a" (value), "d" (port))


#define inw(port) ({ \
uint16_t _v; \
__asm__ __volatile__ ("inw %%dx,%%ax":"=a" (_v):"d" (port)); \
_v; \
})

#define outw(port, value) \
__asm__ __volatile__ ("outw %%ax,%%dx"::"a" (value),"d" (port))


#define inl(port) ({ \
uint32_t _v; \
__asm__ __volatile__ ("inl %%dx,%%eax":"=a" (_v):"d" (port)); \
_v; })

#define outl(port, value) \
__asm__ __volatile__ ("outl %%eax,%%dx"::"a" (value),"d" (port))

#endif  /* _IO_PORT_H */

